package com.example.competionmanagebackend.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

import java.util.Date;

/**
 * 报名信息实体类
 * @TableName registrations
 */
@TableName(value = "registrations")
@Data
public class Registrations {
    /**
     * 报名ID，主键，自增
     */
    @TableId(type = IdType.AUTO)
    private Integer registrationId;

    /**
     * 队伍ID，外键，关联teams表
     */
    private Integer teamId;

    /**
     * 竞赛ID，外键，关联competitions表
     */
    private Integer competitionId;

    /**
     * 报名状态 (0: 未确认, 1: 已确认, 2: 晋级校赛, 3: 晋级省赛, 4: 晋级国赛)
     */
    private Integer status;

    /**
     * 奖项列表，存放每个阶段竞赛的成绩，逗号分隔
     */
    private String awardList;

    /**
     * 作品链接
     */
    private String url;

    /**
     * 提取码
     */
    private String code;

    /**
     * 创建时间，默认当前时间戳
     */
    private Date createdAt;

    /**
     * 更新时间，默认当前时间戳，更新时自动刷新
     */
    private Date updatedAt;

    @TableField(exist = false)
    private String competitionName;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        Registrations other = (Registrations) that;
        return (this.getRegistrationId() == null ? other.getRegistrationId() == null : this.getRegistrationId().equals(other.getRegistrationId()))
                && (this.getTeamId() == null ? other.getTeamId() == null : this.getTeamId().equals(other.getTeamId()))
                && (this.getCompetitionId() == null ? other.getCompetitionId() == null : this.getCompetitionId().equals(other.getCompetitionId()))
                && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
                && (this.getAwardList() == null ? other.getAwardList() == null : this.getAwardList().equals(other.getAwardList()))
                && (this.getUrl() == null ? other.getUrl() == null : this.getUrl().equals(other.getUrl()))
                && (this.getCode() == null ? other.getCode() == null : this.getCode().equals(other.getCode()))
                && (this.getCreatedAt() == null ? other.getCreatedAt() == null : this.getCreatedAt().equals(other.getCreatedAt()))
                && (this.getUpdatedAt() == null ? other.getUpdatedAt() == null : this.getUpdatedAt().equals(other.getUpdatedAt()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getRegistrationId() == null) ? 0 : getRegistrationId().hashCode());
        result = prime * result + ((getTeamId() == null) ? 0 : getTeamId().hashCode());
        result = prime * result + ((getCompetitionId() == null) ? 0 : getCompetitionId().hashCode());
        result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
        result = prime * result + ((getAwardList() == null) ? 0 : getAwardList().hashCode());
        result = prime * result + ((getUrl() == null) ? 0 : getUrl().hashCode());
        result = prime * result + ((getCode() == null) ? 0 : getCode().hashCode());
        result = prime * result + ((getCreatedAt() == null) ? 0 : getCreatedAt().hashCode());
        result = prime * result + ((getUpdatedAt() == null) ? 0 : getUpdatedAt().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", registrationId=").append(registrationId);
        sb.append(", teamId=").append(teamId);
        sb.append(", competitionId=").append(competitionId);
        sb.append(", status=").append(status);
        sb.append(", awardList=").append(awardList);
        sb.append(", url=").append(url);
        sb.append(", code=").append(code);
        sb.append(", createdAt=").append(createdAt);
        sb.append(", updatedAt=").append(updatedAt);
        sb.append("]");
        return sb.toString();
    }
}